﻿<Window x:Class="Microsoft.Communications.Contacts.Widgets.AddressBook"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:widgets="clr-namespace:Microsoft.Communications.Contacts.Widgets"
        Title="Contacts.Net">

  <Window.Resources>
    <!-- Bluebar menu item style -->
    <Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource {x:Type MenuItem}}">
      <Setter Property="Foreground" Value="White"/>
      <Setter Property="Margin" Value="3"/>
    </Style>

    <!-- DataTemplate for displaying Contacts in the listbox.
         This is intended to look similar to the tile view in Vista's Explorer -->
    <DataTemplate x:Key="ContactItemTemplate">
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="Auto"/>
          <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
          <RowDefinition Height="*"/>
          <RowDefinition Height="*"/>
          <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Image Grid.Column="0" Grid.Row="0" Grid.RowSpan="3" Source="{Binding Path=UserTile.Image}"/>
        <TextBlock Grid.Column="2" Grid.Row="0" Text="{Binding Path=Names.Default.FormattedName}"/>
        <TextBlock Grid.Column="2" Grid.Row="1"  Text="{Binding Path=EmailAddresses.Default.Address}"/>
        <TextBlock Grid.Column="2" Grid.Row="2" Text="{Binding Path=PhoneNumbers[Business].Number}"/>
      </Grid>
    </DataTemplate>

    <Style TargetType="{x:Type Menu}" BasedOn="{StaticResource {x:Type Menu}}">
      <Setter Property="Background">
        <Setter.Value>
          <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
            <GradientStop Color="#4B90Df" Offset="0" />
            <GradientStop Color="#295591" Offset=".5" />
            <GradientStop Color="#183D76" Offset="0.51" />
            <GradientStop Color="#325F9E" Offset="1" />
          </LinearGradientBrush>
        </Setter.Value>
      </Setter>
    </Style>
  </Window.Resources>
  
  <DockPanel Name="NavigationRoot">
    <!-- Split the menu into two halves -->
    <DockPanel DockPanel.Dock="Top">
      <DockPanel.Background>
        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
          <GradientStop Color="#4B90Df" Offset="0" />
          <GradientStop Color="#295591" Offset=".5" />
          <GradientStop Color="#183D76" Offset="0.51" />
          <GradientStop Color="#325F9E" Offset="1" />
        </LinearGradientBrush>
      </DockPanel.Background>
      <DockPanel DockPanel.Dock="Right">
        <TextBlock DockPanel.Dock="Left" Foreground="White" VerticalAlignment="Center" Margin="2">
          <Italic>
            Search:
          </Italic>
        </TextBlock>
        <TextBox DockPanel.Dock="Right" Width="150" TextChanged="_FilterWordwheel" x:Name="_wordwheel" Margin="2"/>
      </DockPanel>
      <Menu DockPanel.Dock="Left">
        <MenuItem Header="_New Contact" Name="_newContactButton" Click="_OnNewContact"/>
        <MenuItem Header="_Delete" Name="_deleteContactButton" Click="_OnDelete"/>
        <MenuItem Header="E_xport to vCard" Name="_exportButton" Click="_OnExportVcf"/>
        <MenuItem Header="_Import from vCard" Name="_importButton" Click="_OnImportVcf"/>
        <!--
        <MenuItem Header="_View" Name="_viewButton">
          <ListBox KeyboardNavigation.DirectionalNavigation="Cycle" BorderBrush = "Transparent" Name="_viewList">
            <ListBox.Resources>
              <Style x:Key="{x:Type ListBoxItem}" TargetType="{x:Type ListBoxItem}" >
                <Setter Property="Margin" Value="2, 2, 2, 0" />
                <Setter Property="Template">
                  <Setter.Value>
                    <ControlTemplate>
                      <Border Background="Transparent">
                        <RadioButton IsHitTestVisible="False" Focusable="False" Content="{TemplateBinding ContentPresenter.Content}"  IsChecked="{Binding Path=IsSelected, RelativeSource='{RelativeSource TemplatedParent}', Mode=TwoWay}"/>
                      </Border>
                    </ControlTemplate>
                  </Setter.Value>
                </Setter>
              </Style>
            </ListBox.Resources>
            <ListBoxItem Content="Details" IsSelected="True">
              <ListBoxItem.Tag>
                <widgets:DetailsView/>
              </ListBoxItem.Tag>
            </ListBoxItem>
            <ListBoxItem Content="Thumbnails">
              <ListBoxItem.Tag>
                <widgets:ThumbnailView/>
              </ListBoxItem.Tag>
            </ListBoxItem>
          </ListBox>
        </MenuItem>
        -->
        <Separator/>
        <MenuItem Header="Change Context" Click="_OnSwitchContext"/>
      </Menu>
    </DockPanel>
    <!-- Dock the panel holding the wordwheel to the top, below the menu -->

    <!-- Contact list takes up the rest of the available space -->
    <ListBox x:Name="_contactPanel"
             MouseDoubleClick="_OpenContact"
             ScrollViewer.HorizontalScrollBarVisibility="Disabled"
             ItemTemplate="{StaticResource ContactItemTemplate}">
      <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
          <widgets:AnimatingTilePanel IsItemsHost="True" ItemHeight="64" ItemWidth="256" />
        </ItemsPanelTemplate>
      </ListBox.ItemsPanel>
    </ListBox>
  </DockPanel>
</Window>
